package com.accenture.fd.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.accenture.fd.entity.DesignEntity;

@Mapper
public interface DesignTblDao {

	     @Select("select\r\n" +
	     		"  Screen_ID,\r\n" +
	     		"  Design_type_ID,\r\n" +
	     		"  Design_name,\r\n" +
	     		"  Screen_name,\r\n" +
	     		"  Status_CD,\r\n" +
	     		"  Login_date,\r\n" +
	     		"  Login_by,\r\n" +
	     		"  Update_date,\r\n" +
	     		"  Update_by\r\n" +
	     		"from\r\n" +
	     		"  TB00010\r\n" +
	     		"where\r\n" +
	     		"  Screen_ID = #{screenId}\r\n" +
	     		"  and Design_type_ID = #{designId}")
	     @Results({
	    	 @Result(column = "Screen_ID", property = "screenId"),
	    	 @Result(column = "Design_type_ID", property = "designTypeId"),
	    	 @Result(column = "Design_name", property = "designName"),
	    	 @Result(column = "Screen_name", property = "screenName"),
	    	 @Result(column = "Status_CD", property = "checkStatus"),
	    	 @Result(column = "Login_date", property = "loginDate"),
	    	 @Result(column = "Login_by", property = "loginBy"),
	    	 @Result(column = "Update_date", property = "updateDate"),
	    	 @Result(column = "Update_by", property = "updatedBy"),
	     })
	     List<DesignEntity> getDesignList(@Param("screenId") String screenId, @Param("designId") String designId);

	     @Update("update TB00010 set Status_CD = '1' where Screen_ID = #{screenId} and Design_type_ID = #{designId}")
	     void updateStatus(@Param("screenId") String screenId, @Param("designId") String designId);

	     @Delete("delete from TB00010 where Screen_ID = #{screenId} and Design_type_ID = #{designId}")
	     void delFromDesignTable(@Param("screenId") String screenId, @Param("designId") String designId);

	     @Insert({
	    	 "<script>",
	    	 "insert into TB00010 value ",
	    	 "<foreach collection='entityList' item='entity' index='index' separator=','>",
	    	 "(#{entity.designTypeId},#{entity.screenId},#{entity.screenName},#{entity.designName},",
	    	 "#{entity.checkStatus},#{entity.loginDate},#{entity.loginBy},#{entity.updateDate},",
	    	 "#{entity.updatedBy},#{entity.effectiveFlag},#{entity.versionNumber})",
	    	 "</foreach>",
	    	 "</script>"
	    	})
	     void saveDesignEntityList(@Param(value="entityList") List<DesignEntity> designEntityList);

}